package com.doyens.auth.controller;

import com.doyens.auth.service.SysMenuService;
import com.doyens.common.result.Result;
import com.doyens.model.system.SysMenu;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.tomcat.util.digester.Rules;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/system/sysMenu")
@Api(tags = "菜单模块")
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;
    @ApiOperation("获取菜单")
    @GetMapping("/findNodes")
    public Result findNodes(){
       List<SysMenu> sysMenuList= sysMenuService.findNodes();
       return Result.ok(sysMenuList);
    }
    @ApiOperation("添加菜单")
    @PostMapping("/save")
    public Result save(@RequestBody SysMenu sysMenu){
        sysMenuService.save(sysMenu);
        return Result.ok();
    }
    @ApiOperation("修改菜单")
    @PutMapping("/update")
    public Result update(@RequestBody SysMenu sysMenu){
        sysMenuService.updateById(sysMenu);
        return Result.ok();
    }
    @ApiOperation("删除菜单")
    @DeleteMapping("/del/{id}")
    public Result del(@PathVariable int id){
        sysMenuService.removeMenuById(id);
        return Result.ok();
    }
}
